<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>轩盛金融</title>
    <meta name="keywords" content="轩盛金融">
    <meta name="description" content="轩盛金融">

    <link rel="shortcut icon" href="favicon.ico">
    <link href="__CSS__/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
    <link href="__CSS__/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
    <link href="__CSS__/animate.min.css" rel="stylesheet">
    <link href="__CSS__/style.min862f.css?v=4.1.0" rel="stylesheet">
    <link href="__JS__/layui/css/layui.css"rel="stylesheet">

</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>所有表单元素 <small>包括自定义样式的复选和单选按钮</small></h5>
                        <div class="ibox-tools">
                            <a class="collapse-link" href="{:url('Ad/home')}">
                                <i class="fa fa-reply"></i>
                            </a>

                        </div>
                    </div>
                    <div class="ibox-content">
                        <form method="post" action="{:url('Ad/homeEdit')}" class="form-horizontal layui-form" enctype="multipart/form-data">
                            {volist name="formData" id="fd"}
                            <div class="form-group">
                                <label for="ad_name" class="col-sm-3 control-label">广告名称</label>

                                <div class="col-sm-6">
                                    <input type="text" lay-verify="required" id="ad_name" name="ad_name" class="form-control layui-input" value="{$fd.ad_name}">
                                </div>
                            </div>

                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label for="media_type" class="col-sm-3 control-label">广告类型</label>

                                <div class="col-sm-6">
                                    <input type="text" id="media_type" name="media_type" class="form-control" value="首页轮播图" disabled="disabled">
                                </div>
                            </div>
                            
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label for="pid" class="col-sm-3 control-label">广告顺序</label>

                                <div class="col-sm-6">
                                    <input type="text" lay-verify="required" id="pid" name="pid" class="form-control" placeholder="值越小,顺序越前" value="{$fd.pid}">
                                </div>
                            </div>

                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label for="ad_pic" class="col-sm-3 control-label">广告图片</label>
                                <div id="photo_box">
                                    {if condition="$formData[0]['ad_pic']"}      
                                        <div class="col-sm-6">
                                            <img width="100%;" src="{$fd.ad_pic}" alt="广告图片">
                                            <button id="change_photo" class="btn btn-warning pull-right">更改图片</button>
                                            <!-- <input type="file" lay-verify="required" id="ad_pic" name="ad_pic" class="form-control" accept="image/*"> -->
                                        </div>
                                    {else/}
                                        <div class="col-sm-6">
                                            <input type="file" lay-verify="required" id="ad_pic" name="ad_pic" class="form-control" accept="image/*">
                                        </div>
                                    {/if}
                                </div>            
                            </div>

                            <input type="hidden" value="{$fd.id}" name="id">
                            <input type="hidden" name="type" value="1">

                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <div class="col-sm-2 col-sm-offset-7">
                                    <button lay-submit lay-filter="upload" class="btn btn-primary btn-block" type="submit">确认修改</button>
                                    
                                </div>
                            </div>
                            {/volist}
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script src="__JS__/jquery.min.js?v=2.1.4"></script>
    <script src="__JS__/bootstrap.min.js?v=3.3.6"></script>
    <script src="__JS__/layui/layui.js"></script>
    <script>
        // 引用layui
        layui.use(['layer', 'form'], function(){
          var layer = layui.layer;
          var form = layui.form;
        });

        $('#change_photo').on('click',function(event){
            event.preventDefault();
            $('#photo_box').html(
                '<input class="col-sm-6" type="file" name="ad_pic" accept="image/*"/>'
            );
        })
    </script>
</body>

</html>
